package cc.comac.mom.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import cc.comac.mom.api.EquipSpareInWarehouseService;
import cc.comac.mom.bean.EquipSpareInWarehouse;
import cc.comac.mom.bean.EquipSpareInWarehouseBean;
import cc.comac.mom.bean.ResultDev;
import cc.comac.mom.util.ResultBean;

@RestController
@RequestMapping("/EquipSpareInWarehouse")
public class EquipSpareInWarehouseController {

	@Autowired
	private EquipSpareInWarehouseService equipSpareInWarehouseService;

	// 库存数据保存
	@RequestMapping("/spareInwarehouse")
	public ResultBean spareInwarehouse(@RequestBody EquipSpareInWarehouseBean equipSpareInWarehouseBean) {
		ResultBean resultBean = new ResultBean(true);
		try {
			resultBean = equipSpareInWarehouseService.spareInwarehouse(equipSpareInWarehouseBean);
		} catch (RuntimeException e) {
			resultBean.setErrorMessge(e.getMessage());
			return resultBean;
		}
		return resultBean;
	}

	@RequestMapping("/selectBySomeField")
	public ResultBean selectBySomeField(@RequestBody EquipSpareInWarehouse equipSpareInWarehouse) {
		ResultBean selectBySomeField = equipSpareInWarehouseService.selectBySomeField(equipSpareInWarehouse);
		return selectBySomeField;
	}

	// 更新库存数量
	@RequestMapping("/updateInWarehouseSpareQuantity")
	public ResultBean updateInWarehouseSpareQuantity(@RequestBody List<EquipSpareInWarehouse> list) {

		ResultBean resultBean = equipSpareInWarehouseService.updateInWarehouseSpareQuantity(list);
		return resultBean;
	}

	// 编辑入库单数据
	@RequestMapping("/updateInWarehouseSpareData")
	public ResultBean updateInWarehouseSpareData(@RequestBody EquipSpareInWarehouseBean euipSpareInWarehousebean) {

		ResultBean resultBean = equipSpareInWarehouseService.updateInWarehouseSpareData(euipSpareInWarehousebean);
		return resultBean;
	}

	// 批量删除入库单数据
	@RequestMapping("/batchDelete")
	public ResultBean batchDelete(@RequestBody List<EquipSpareInWarehouse> inWarehouseList) {
		ResultBean resultBean = equipSpareInWarehouseService.batchDelete(inWarehouseList);
		return resultBean;
	}

}
